package com.wsy.wsyojcodesandbox.security;

import java.security.Permission;

public class MySecurityManager extends SecurityManager{

    /**
     * 该程序是否可读？
     * @param file
     */
    @Override
    public void checkRead(String file) {
        throw new SecurityException("checkRead权限异常：" + file);
    }

    /**
     * 可执行？
     * @param cmd
     */
    @Override
    public void checkExec(String cmd) {
        throw new SecurityException("checkExec权限异常：" + cmd);
    }

    /**
     * 可写？
     * @param file
     */
    @Override
    public void checkWrite(String file) {
        throw new SecurityException("checkWrite权限异常：" + file);
    }

    /**
     * 可删？
     * @param file
     */
    @Override
    public void checkDelete(String file) {
        throw new SecurityException("checkDelete权限异常：" + file);
    }

    /**
     * 可连接网络？
     * @param host
     * @param port
     */
    @Override
    public void checkConnect(String host, int port) {
        throw new SecurityException("checkConnect权限异常：" + host + " port: " + port);
    }

    /**
     * 检查所有权限
     * @param perm
     */
    @Override
    public void checkPermission(Permission perm) {
        System.out.println("默认不做限制...");
        System.out.println(perm);
        super.checkPermission(perm);
    }
}
